package org.jeecg.modules.sensor.util;

import org.apache.commons.codec.binary.Base64;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class TokenUtil {
	private static final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
    public static String decodeBase64(String encodedStr)
    {
    	byte[] debytes = Base64.encodeBase64(encodedStr.getBytes());
        return new String(debytes);
    }
    public static String encodeBCrypt(String token){
        return encoder.encode(token);
    }
    public static void main(String[] args) {
//        String token = "br7njz5c"; //页面上的token
//        String midToken = TokenUtil.encodeBCrypt(token);//生成中间token
//        System.out.println(midToken);
//        String hashToken = TokenUtil.decodeBase64(midToken); //生成hashToken
//        System.out.println(hashToken);
//        String URL = "https://gis.aliyun-iot-share.com/auth/gis/" + hashToken + "/866049dd0f03471081451189c0bdc570";
//        System.out.println("您的分享url为: " + URL);
    }
}
